import Book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class
Main {
    public static User login() {    //向上转型,返回具体的父类
        System.out.println("请输入你的姓名:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("请输入你的身份，1：管理员  2：普通用户");
        int choice = scanner.nextInt();
        if(choice == 1) {               //从这里就分开了普通用户和管理员
            return new AdminUser(name);
        }else {
            return new NormalUser(name);
        }
    }
    public static void main(String[] args) {
        BookList booklist = new BookList();//引用接口
        User user = login();  //多态
        while (true) {
            int choice = user.menu();
            //根据返回的choice来执行对应操作
            user.doOperation(choice, booklist);
        }
    }
}